<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>

</body>

</html>
<script>
    var str = prompt('请输入字符串:')
    // 统计没个字符串出现的次数
    var o = {};
    for (var i = 0; i < str.length; i++) {
        var chars = str.charAt(i);
        if (o[chars]) {
            o[chars]++;
        } else {
            o[chars] = 1;
        }
    }
    var max = 0
    var ch = ''
    // 遍历对象
    for (var k in o) {
        if (o[k] > max) {
            max = o[k]
            ch = k
        }
    }
    alert('出现次数最多的字符是：' + ch + ',共出现了' + max + '次')
</script>